package com.bjtu.laorenyouhao.laoren.service.impl;

import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.bjtu.common.utils.PageUtils;
import com.bjtu.common.utils.Query;

import com.bjtu.laorenyouhao.laoren.dao.JianhurenDao;
import com.bjtu.laorenyouhao.laoren.entity.JianhurenEntity;
import com.bjtu.laorenyouhao.laoren.service.JianhurenService;
import org.springframework.util.StringUtils;


@Service("jianhurenService")
public class JianhurenServiceImpl extends ServiceImpl<JianhurenDao, JianhurenEntity> implements JianhurenService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {

        String key = (String) params.get("key");
        QueryWrapper<JianhurenEntity> queryWrapper = new QueryWrapper<JianhurenEntity>();
        if (StringUtils.hasLength(key)) {
            queryWrapper.eq("id", key).or().like("name", key);
        }
        IPage<JianhurenEntity> page = this.page(
                new Query<JianhurenEntity>().getPage(params),
                queryWrapper
        );

        return new PageUtils(page);
    }

}